package cn.tedu.boot01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {
    @RequestMapping("/bmi1")
    @ResponseBody
    //前后端数据不一致时使用@RequestParam("height")转换Double h;
    public String bmi(@RequestParam("height") Double h, @RequestParam("weight") Double w){
        //soutp
        System.out.println("w = " + w + ", h = " + h);
        double bmi = w/(h*h);
        System.out.println(bmi);
        if (bmi < 27){
            System.out.println("有点胖，BMI值数为："+bmi);
        }else if (bmi < 24){
            System.out.println("正常，BMI值数为："+bmi);
        }else if (bmi < 18.5){
            System.out.println("偏瘦，BMI值数为："+bmi);
        }
        return "有点胖";
    }
}
